package com.tsd.system.service;

import com.tsd.core.vo.HttpResult;
import com.tsd.core.vo.PageBean;
import com.tsd.system.entity.SysResourceExt;
import com.tsd.system.entity.SysUser;
import com.tsd.system.entity.SysUserExt;
import com.tsd.system.entity.SysUserRole;
import com.tsd.system.vo.MyUserInfo;

import java.util.List;
import java.util.Map;


/**
 * 描述：SysUser服务实现层接口
 *
 * @author Hillpool
 * @date 2019/03/12 12:20:51
 */
public interface SysUserService {

    /**
     * 描述：根据id获取SysUser
     *
     * @param id
     */
    SysUser getSysUserById(Long id) throws Exception;

    Map<String, Object> getSysUserParamsById(Long id) throws Exception;

    SysUserExt queryBySid(String sid) throws Exception;

    /**
     * 描述：保存或更新SysUser
     *
     * @param record
     * @param opUser
     */
    SysUserExt saveSysUser(SysUserExt record, SysUser opUser) throws Exception;

    void saveSysUser4Sync(SysUser record) throws Exception;

    /**
     * 描述：保存或更新SysUser及其角色
     *
     * @param record
     * @param opUser
     */
    void saveSysUserRole(SysUser record, SysUser opUser, SysUserRole sysUserRole) throws Exception;

    /**
     * 描述：保存或更新SysUser及其角色(多角色)
     *
     * @param record
     * @param opUser
     */
    void saveSysUserRoleList(SysUser record, SysUser opUser, List<String> roleSidList) throws Exception;

    /**
     * 描述：根据id删除SysUser
     *
     * @param id
     */
    void deleteSysUser(Long id, SysUser opUser) throws Exception;

    /**
     * 描述：根据sids删除SysUser
     *
     * @param sids
     */
    HttpResult<String> batchDeleteSysUser(List<String> sids, SysUser opUser) throws Exception;

    /**
     * 描述：根据params分页查询SysUser
     *
     * @param params
     * @param page
     */
    List<SysUserExt> findSysUsers(Map<String, Object> params, PageBean page) throws Exception;

    /**
     * 描述：根据params查询SysUser
     *
     * @param params
     */
    List<SysUserExt> findSysUsers(Map<String, Object> params) throws Exception;

    /**
     * 描述：根据params分页查询SysUser及部门、职务、人员特性等
     *
     * @param params
     * @param page
     */
    List<Map<String, Object>> findSysUserParams(Map<String, Object> params, PageBean page) throws Exception;

    void resetPwd(String userId, String password) throws Exception;

    HttpResult<String> changePwd(SysUser opUser, String sid, String password, String newPassword) throws Exception;

    List<SysUserExt> queryByMobile(String mobile) throws Exception;

    SysUserExt loginUser(Map<String, Object> map) throws Exception;

    SysUserExt loginUser(String loginId, String password) throws Exception;

    SysUser queryByLoginId(String loginId) throws Exception;

    /**
     * 验证账号和密码是否通过
     *
     * @param loginId
     * @param password
     * @return
     */
    SysUserExt checkUserLoginPassword(String loginId, String password) throws Exception;

    void updateLog(SysUser user);

    List<SysUserExt> findUserByOrgSid(String orgSid) throws Exception;

    /**
     * 描述：根据params获取现场人员、离职人员、冻结人员信息
     *
     * @param params
     */
    List<SysUserExt> findSysUsersByParams(Map<String, Object> params) throws Exception;

    /**
     * 获取未绑定的用户
     *
     * @param params
     * @return
     * @throws Exception
     */
    List<SysUserExt> findUnBindSysUser(Map<String, Object> params) throws Exception;

    /**
     * 当前账户所绑定的员工是否已经绑定其他账户
     *
     * @param newUser
     * @return 其他账户
     * @throws Exception
     */
    SysUserExt personHasBindOtherUser(SysUserExt newUser) throws Exception;

    SysUserExt getSysUserByOpenId(String openId) throws Exception;

    void saveMyUserInfo(MyUserInfo myUserInfo, SysUser opUser) throws Exception;

    List<SysResourceExt> findUserPermission(String userSid, List<String> permission) throws Exception;

    /**
     * 重置内置管理员
     *
     * @param loginId
     * @param password
     * @param opUser
     * @throws Exception
     */
    HttpResult<String> resetAdmin(String loginId, String password, SysUser opUser) throws Exception;

    int getAccountSetUcLimit(String dataSource) throws Exception;

    /**
     * 描述：根据params分页查询SysUser
     *
     * @param params
     * @param page
     */
    List<SysUserExt> findSysUserBaseInfos(Map<String, Object> params, PageBean page) throws Exception;

    /**
     * 描述：根据params查询SysUser
     *
     * @param params
     */
    List<SysUserExt> findSysUserBaseInfos(Map<String, Object> params) throws Exception;

    /**
     * 初始化默认管理员
     * @param admin
     * @throws Exception
     */
    void initDefaultAdmin(SysUserExt admin) throws Exception;

    /**
     * 登出
     * @param user
     * @throws Exception
     */
    void logout(SysUser user) throws Exception;
}
